package com.ydgk.servlet;

import com.ydgk.bean.Commodity;
import com.ydgk.service.CommService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "findByIdServlet", urlPatterns = "/findByIdServlet.action")
public class findByIdServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String id = request.getParameter("id");
        CommService commService = new CommService();
        Commodity commodity = commService.findById(Integer.parseInt(id));
        request.setAttribute("msg","");
        request.setAttribute("comm",commodity);
        request.getRequestDispatcher("coommDeatil.jsp").forward(request,response);
    }


}
